Skip to content

Introduce ub variant for Result#1226

Open
mdittmer wants to merge 5 commits into
AeneasVerif:mainfrom
mdittmer:ub
Open

Introduce ub variant for Result#1226
mdittmer wants to merge 5 commits into
AeneasVerif:mainfrom
mdittmer:ub

Conversation

@mdittmer

Copy link
Copy Markdown
Contributor

This change introduces a Result variant intended to model undefined behaviour (UB). The intent is to allow unsafe definitions and theorems to introduce proof obligations that formalize the conditions under which unsafe operations introduce undefined behaviour. Using a Result variant provides a natural abstraction asserting that undefined behaviour at a particular step determines all subsequent behaviour as undefined.

Towards #1225

AI assisted this PR as my "Lean tutor", helping me know where to look and what abstractions to reach for but not authoring any code.

This change introduces a `Result` variant intended to model undefined
behaviour (UB). The intent is to allow unsafe definitions and theorems
to introduce proof obligations that formalize the conditions under which
unsafe operations introduce undefined behaviour. Using a `Result`
variant provides a natural abstraction asserting that undefined
behaviour at a particular step determines all subsequent behaviour as
undefined.

Towards AeneasVerif#1225
@sonmarcho

Copy link
Copy Markdown
Member

Thanks for this! What I had in mind was not to modify Result but Error (UB is one kind of error).

@mdittmer

Copy link
Copy Markdown
Contributor Author

Yeah. I would appreciate more discussion about this question. I tend to agree with @joshlf 's assessment. The point that I would emphasize is that, AFAICT, developers can quite reasonably assume that Result.fail implies (a certain kind of) termination. The curious thing about UB, as I understand it, is that all bets are off: in the presence of UB you cannot be confident that a program will terminate or diverge; in fact, you cannot be confident in much of anything!

@joshlf

joshlf commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

in fact, you cannot be confident in much of anything!

Result.nasaldemons?

Repairs deliberately map `.ub => ⟨False⟩` in `mvcgen` bindings for
`Result.instWP`. This matches the intuition that UB should be forbidden
rather than another case for reasoning about weakest preconditions.

Towards AeneasVerif#1225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants